Repository navigation
fix(node,gnn): ESM import of @ruvector/node resolves; TensorCompress input no longer aborts Node (@ruvector/node 0.1.25) - #1335
Merged
Conversation
package.json pointed the "import" condition and "module" field at dist/index.mjs and dist/gnn.mjs, but the build never emitted them: the ESM and CJS tsc passes shared outDir, so the CJS pass overwrote the ESM output. Every `import ... from '@ruvector/node'` (and './gnn') failed with ERR_MODULE_NOT_FOUND; only require() worked. Ship CJS only and route all conditions to it, with "types" first. A real ESM build would not help: @ruvector/core assigns module.exports from the native addon, so cjs-module-lexer cannot see its named exports. Node's CJS interop gives ESM callers named and default exports from dist/*.js. The single remaining tsc pass now emits the .d.ts files the ESM pass used to produce; dist output is byte-identical to 0.1.24 apart from the map. Adds test/exports.test.mjs (node --test previously ran zero tests). Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvector/node re-exports TensorCompress from @ruvector/gnn. Three
JS-reachable paths panicked inside the addon, which aborts the whole
Node process (SIGABRT, "failed to initiate panic") instead of throwing:
- compressWithLevel({levelType: 'pq8'|'pq4', subvectors: 0}) hit an
`expect` on checked_rem in compress_pq8/compress_pq4.
- decompress(json) of a PQ8/PQ4 tensor with subvector_dim 0 divided by
zero. decompress parses caller-supplied (e.g. stored) JSON.
- decompress also pre-allocated `dim` floats from that JSON before
validating any code, so {codes:[0], codebooks:[[]], subvector_dim:
2^40, dim: 2^40} requested a 4 TB buffer. A codes/codebooks length
mismatch silently returned a short vector.
PQ layouts are now validated (non-zero subvector_dim, matching code and
codebook counts, checked dim product, every centroid index in range)
before allocating, so output size is bounded by the input. The napi
wrapper rejects subvectors/centroids > 255 instead of wrapping via
`as u8` (256 became 0).
Red tests: Rust unit tests in compress.rs and subprocess JS tests in
crates/ruvector-gnn-node/test/dimensions.test.js (both SIGABRT against
the published @ruvector/gnn 0.1.25 binary, pass on this build).
Co-Authored-By: claude-flow <ruv@ruv.net>
ruvnet
added a commit
that referenced
this pull request
Nov 4, 2026
Per-crate version overrides (workspace 2.3.0 is already published): - ruvector-rabitq 2.3.0 -> 2.3.1 (#1325) - ruvector-cnn 2.3.0 -> 2.3.1 (#1336) - ruvector-gnn 2.3.0 -> 2.3.1 (#1335) - ruvector-tiny-dancer-core 2.3.0 -> 2.3.1 (#1321) - ruvector-graph 2.3.2 -> 2.3.3 (#1331) - ruvector-graph-wasm 2.3.0 -> 2.3.1 (#1331) - ruvector-gnn-node 2.3.0 -> 2.3.1 (#1335) Dependent reqs raised so the published wasm/node crates pull the fixed cores: rabitq-wasm -> rabitq 2.3.1, cnn-wasm -> cnn 2.3.1, graph-wasm -> graph 2.3.3, gnn-node -> gnn 2.3.1. ruvector-rabitq-wasm 0.1.1, ruvector-cnn-wasm 0.1.1 and ruvllm-wasm 2.0.4 keep their already-unpublished repo versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review of
@ruvector/node0.1.24 (npm) and the native code it re-exports.Fixes
1. ESM
importof@ruvector/nodefails for everyone (HIGH) —npm/packages/node/package.jsonexports[".|./gnn"].importandmodulepointed atdist/index.mjs/dist/gnn.mjs, which the build never produced. The ESM and CJStscpasses sharedoutDir, so CJS overwrote ESM.import { VectorDB } from '@ruvector/node'→ERR_MODULE_NOT_FOUNDon the published tarball; onlyrequireworked.Now the package is CJS-only: every condition points at
dist/*.js, withtypesfirst. A real ESM build would not help, because@ruvector/coresetsmodule.exports = nativeModule, so Node cannot statically see its named exports. The single tsc pass now emits the.d.tsfiles.dist/is byte-identical to the published 0.1.24. Bumped to 0.1.25.Added
test/exports.test.mjs(node --testran 0 tests before): 4/5 failed before the fix, 5/5 pass after. Also checked from a packed tarball in a fresh"type":"module"consumer: runtime import works, andtscpasses undernodenextandbundler.2.
TensorCompressinput aborts the Node process (HIGH) —crates/ruvector-gnn/src/compress.rsThese are re-exported from
@ruvector/node, and each one SIGABRTs the process instead of throwing:compressWithLevel(e, {levelType:'pq8'|'pq4', subvectors:0})hits anexpectonchecked_rem.decompress(json)withsubvector_dim: 0divides by zero. The JSON is caller-supplied or stored data.decompressallocateddimfloats from that JSON before validating anything, sosubvector_dim = dim = 2^40asked for 4 TB. A mismatch between the codes and codebooks counts silently returned a short vector.centroids: 0compresses to a tensor thatdecompressrejects. That is a silent, undecodable result rather than an abort.CompressionLevelConfig:subvectors/centroidsas u8wrapped (256 → 0). Values above 255 are now rejected.Red tests: the Rust units in
compress.rsand subprocess JS tests incrates/ruvector-gnn-node/test/dimensions.test.jsboth SIGABRT on the published@ruvector/gnn0.1.25 binary and pass on this build.cargo test -p ruvector-gnnpasses 229/229, gnn JS tests 61/61, and clippy is clean for the touched code.Not changed (other lanes / packages)
@ruvector/coreindex.d.tstypesvectorasFloat32Array | number[], but the runtime rejectsnumber[]("Get TypedArray info failed").k: -1, anddimensions: 0(fix(core): reject nonfinite vectors and duplicate IDs before index mutation #1316 territory).@ruvector/gnn0.1.25 on npm predates the dimension-validation fixes already on main (6e1fce6, cce6a7e). ItsdifferentiableSearch/forwarddimension mismatches andnew RuvectorLayer(0,0,0,…)still abort in the published binary, so it needs a republish.Publish (not done here)
@ruvector/node:cd npm/packages/node && npm install && npm run build && npm test && npm publish(prepublishOnly builds; needs typescript installed). It has no optionalDependencies, sooptional-deps-resolvable-on-npmis unaffected.@ruvector/gnn: bumpcrates/ruvector-gnn-node/package.jsonversionand theoptionalDependenciespins to 0.1.26 in one commit, then runbuild-gnn.ymlwith workflow_dispatch andpublish=truefrom that commit. That workflow publishes the platform packages before the main one.optional-deps-resolvable-on-npmonly scansnpm/packages, so gnn is outside its scope.@ruvector/node's^0.1.15range picks up 0.1.26 automatically.🤖 Generated with claude-flow